
Page({
    data: {
        

        
    },
    onLoad:function(opt){
    getApp().getUserInfo().then(res=>{
      var header={
             'openid':res.openid, //公用请求头
             'content-type': 'application/json'
         }
       this.setData({
        userInfo:res.obj,
        header:header
       })  
     })




      this.setData({
        type:opt.type,
        equId:opt.equId,
        show:opt.show
      })
      var address= wx.getStorageSync('address');
         console.log("address")

        var userInfo= wx.getStorageSync('userInfo');
        this.setData({
            userInfo:userInfo,
            address:address
       })
      var _self=this;
         wx.request({
            url: getApp().globalData.baseUrl+'/company/insurance',
            method:"get",
            data:{
              openid:this.data.userInfo.openid,
              equId:this.data.equId||'',
              source:this.data.type,
              province:this.data.address.province,
              city:this.data.address.city
            },
            header: {
                'openid':this.data.userInfo.openid, //公用请求头
                'content-type': 'application/json'
            },
            success: function(res) {
             console.log(res)
            
         }
       })
    },
    onShow:function(){

        // wx.getStorage({
        //     key: 'openId',
        //     success: function(res) {
        //         console.log("fff",res)
        //        if(!res){
        //         wx.reLaunch({
        //             url: '../login/login'
        //           })
        //        }
        //     },
        //     fail:function(){
        //         wx.reLaunch({
        //             url: '../login/login'
        //           })
        //     }
        //   })
    },
    onMyEvent:function(e){
        console.log(e.detail)
        // this.setData({
        //     item:e.detail
        // })
    },
    turnDetail:function(e){
      console.log(e.currentTarget.dataset.code)
        wx.navigateTo({
        url: '/pages/webView/webView?id='+e.currentTarget.dataset.code,
      })
    },
    callPhone:function(){
         wx.makePhoneCall({
          phoneNumber: '13971069658' //仅为示例，并非真实的电话号码
        })
    },
    turnPage:function(){
       

          wx.switchTab({
                  url: '../../pages/home/home'
          })
       
    },
     onShareAppMessage:function(){
         return {
              title: '给设备上保险，保平安',
              path: '/pages/bx/bx?show=1'
            }
    },
    onShareTimeline:function(){
         return {
              title: '给设备上保险，保平安',
              path: '/pages/bx/bx?show=1'
            }
    },
});